package com.situ.javase.day5;

import java.util.Scanner;

import org.junit.Test;

public class HomeWork {

	@Test
	public void test78() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一个字符串");
		String str = scanner.next();// "abcba"
		char[] array = str.toCharArray();
		// 初始认为是回文
		boolean isHuiWen = true;
		for (int i = 0; i < array.length / 2; i++) {
			if (array[i] != array[array.length - 1 - i]) {
				isHuiWen = false;
				// 对称位置只要找到一个不相等，就不是回文
				break;
			}
		}
		
		if (isHuiWen) {
			System.out.println("是回文");
		} else {
			System.out.println("不是回文");
		}
	}
	
	// 17、输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一行字符串：");
		String str = scanner.nextLine();
		char[] array = str.toCharArray();
		int numberCount = 0;
		int blankCount = 0;
		int letterCount = 0;
		int otherCount = 0;
		for (int i = 0; i < array.length; i++) {
			if (array[i] >= '0' && array[i] <= '9') {
				numberCount++;
			} else if ((array[i] >= 'a' && array[i] <= 'z') 
					|| (array[i] >= 'A' && array[i] <= 'Z')) {
				letterCount++;
			} else if (array[i] == ' ') {
				blankCount++;
			} else {
				otherCount++;
			}
		}
		
		System.out.println("字符串中数字出现的次数： " + numberCount);
		System.out.println("字符串中空格出现的次数： " + blankCount);
	}
	
	
	// 18、int[] = {23,4,56,78,99,22,67}找出数组里面的最大值和最小值
	@Test
	public void test3() {
		int[] array = {23,4,56,78,99,22,67};
		int min = array[0];
		int max = array[0];
		for (int i = 0; i < array.length; i++) {
			if (min > array[i]) {
				min = array[i];
			}
			if (max < array[i]) {
				max = array[i];
			} 
		}
		
		System.out.println("最小值：" + min);
		System.out.println("最大值：" + max);
	}
	
	@Test
	public void test44() {
		char c = 126;
		System.out.println(c);
		byte b  = 45;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
